package com.youlu.campus.entity.complaint;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.youlu.campus.base.base.EntityBase;
import lombok.Data;
import lombok.ToString;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Date;
import java.util.List;

/**
 * 商户号处理
 */
@Data
@ToString
@Document(collection = "merchant_complaint")
public class MerchantComplaint extends EntityBase {
    //待处理
    public final static String COMPLAINT_PENDING = "PENDING";
    //处理中
    public final static String COMPLAINT_PROCESSING = "PROCESSING";
    //已处理完成
    public final static String COMPLAINT_PROCESSED = "PROCESSED";

    /**
     * 商户号id
     */
    @Indexed
    private String merchantId;
    /**
     * 商户号名称
     */
    private String merchantName;

    /**
     * 投诉单号
     */
    @JsonProperty(value = "complaint_id")
    //@Indexed
    private String complaintId;

    /**
     * 投诉时间 格式化：yyyy-MM-dd HH:mm:ss
     */
    @Indexed
    @JsonProperty(value = "complaint_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date complaintTime;

    /**
     * 投诉详情
     */
    @JsonProperty(value = "complaint_detail")
    private String complaintDetail;

    /**
     * 投诉状态
     */
    @JsonProperty(value = "complaint_state")
    private String complaintState = COMPLAINT_PENDING;

    /**
     * 被诉商户号
     */
    @JsonProperty(value = "complainted_mchid")
    private String complaintedMchId;

    /**
     * 投诉人联系方式
     */
    @JsonProperty(value = "payer_phone")
    @Indexed(background = true)
    private String payerPhone;

    /**
     * 投诉人openid
     */
    @JsonProperty(value = "payer_openid")
    private String payerOpenid;

    /**
     * 投诉资料列表
     */
    @JsonProperty(value = "complaint_media_list")
    private List<ComplaintMediaList> complaintMediaList;

    /**
     * 投诉单关联订单信息
     */
    @JsonProperty(value = "complaint_order_info")
    private List<ComplaintOrderInfo> complaintOrderInfo;

    /**
     * 投诉单是否已全额退款
     */
    @JsonProperty(value = "complaint_full_refunded")
    private Boolean complaintFullRefunded = Boolean.FALSE;

    /**
     * 问题描述-用户发起投诉前选择的faq标题
     */
    @JsonProperty(value = "problem_description")
    private String problemDescription;

    /**
     * 是否有待回复的用户留言
     */
    @JsonProperty(value = "incoming_user_response")
    private Boolean incomingUserResponse = Boolean.FALSE;

    /**
     * 用户投诉次数
     */
    @JsonProperty(value = "user_complaint_times")
    private Integer userComplaintTimes = 1;

    /**
     * 触发本次投诉通知回调的具体动作类型
     */
    private String actionType;

    private List<ReplyUserComplaint> replyUserComplaintList;

    @Transient
    private String outTradeNo;

    private String refundStatus;

    @Transient
    private Integer amount = 0;
    @Transient
    private String transactionId;
    @Transient
    private String activityName;
    @Transient
    private String comment;

}
